<%@ page import="java.util.List" %>
<%@ page import="com.huang.info.UserInfo" %><%--
  Created by IntelliJ IDEA.
  User: Jimmy
  Date: 2022/4/29
  Time: 11:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <style type="text/css">
        legend{font-size: 12pt; color: black;}
    </style>

    <script src="<%=request.getContextPath()%>/js/jimmyhuang.js" type="text/javascript" charset="utf-8"></script>

    <script type="text/javascript">

        $(function (){

            $("#loginOut").click(function (){

                //跳转到LoginOutServlet
                window.location.href = "<%=request.getContextPath()%>/loginOut"

            })

        })

    </script>

</head>
<body>

    <tr>
        <td>欢迎登陆：<span style="color: red">${userInfo.phone}</span></td>
        <td><a id="loginOut">退出登陆</a></td>
    </tr>

    <form action="" method="post" id="main1">
        <fieldset id="field">
            <legend>所有用户-></legend>
            <table border="0" cellpadding="10">
                <%--表头--%>
                <tr>
                    <td><b>No./Name</b></td>
                    <td><b>Phone</b></td>
                    <td><b>Password</b></td>
                    <td><b>Sex</b></td>
                    <td><b>Hobby</b></td>
                    <td><b>Age</b></td>
                    <td><b>Header</b></td>
                    <td><b>Education</b></td>
                    <td><b>Myself</b></td>
                    <td><b>操作</b></td>
                </tr>

<%--                在servlet中使用了setAttribute方法，所有在这里需要用getAttribute方法接受，注意丢的是什么，就要用什么去接--%>
                <%
                    List<UserInfo> userInfoList = (List<UserInfo>)request.getAttribute("userList");
                    //判断集合是否为空
                    if (userInfoList == null || userInfoList.size() == 0) {


                %>
                <tr>
                    <td colspan="9">没有数据！</td>
                </tr>

                <%
                    } else{
                        for (int i = 0; i < userInfoList.size(); i++) {

                %>

                <tr>
                    <td><%=i+1%></td>
                    <td><%= userInfoList.get(i).getPhone()%></td>
                    <td><%= userInfoList.get(i).getPassword()%></td>
                    <td><%= userInfoList.get(i).getSex()%></td>
                    <td><%= userInfoList.get(i).getHobby()%></td>
                    <td><%= userInfoList.get(i).getAge()%></td>
                    <td><%= userInfoList.get(i).getHeader()%></td>
                    <td><%= userInfoList.get(i).getEducation()%></td>
                    <td><%= userInfoList.get(i).getMyself()%></td>
                    <td><input type="button" id="edit" value="编  辑">
                        <input type="button" id="delete" value="删  除">
                    </td>
                </tr>

                <% }}%>


            </table>
        </fieldset>
    </form>
</body>
</html>
